package com.myblog.demo.service;

import com.myblog.demo.entity.ArticleInfo;
import com.myblog.demo.entity.UserInfo;
import com.myblog.demo.entity.vo.ArticleInfoVO;
import com.myblog.demo.mapper.ArticleMapper;
import org.apache.ibatis.annotations.Param;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;


@Service
public class ArticleService {
    @Autowired
    private ArticleMapper articleMapper;

    public int add(ArticleInfo articleInfo){
        return articleMapper.add(articleInfo);
    }

    public ArticleInfo getDetailByIdAndUid(Integer id, Integer uid){
        return articleMapper.getDetailByIdAndUid(id, uid);
    }

    public int update(ArticleInfo articleInfo){
        return articleMapper.update(articleInfo);
    }

    public ArticleInfoVO getDetailById(Integer id){
        return articleMapper.getDetailById(id);
    }

    public int addRCount(Integer id){
        return articleMapper.addRCount(id);
    }

    public List<ArticleInfo> getListByUid(Integer uid){
        return articleMapper.getListByUid(uid);
    }

    public List<ArticleInfo> getDraftList(Integer uid){
        return articleMapper.getDraftList(uid);
    }

    public int delByIdAndUid(Integer id, Integer uid){
        return articleMapper.delByIdAndUid(id, uid);
    }

    public List<ArticleInfo> getListByPage(Integer pageSize, Integer offset){
        return articleMapper.getListByPage(pageSize, offset);
    }

    public int getCount(){
        return articleMapper.getCount();
    }

    public int getCountByUsername(String username){
        return articleMapper.getCountByUsername(username);
    }

    public int addDraft(ArticleInfo articleInfo){
        return articleMapper.addDraft(articleInfo);
    }

    public int saveDraft(ArticleInfo articleInfo){
        return articleMapper.saveDraft(articleInfo);
    }

    public UserInfo getUserInfoByArtId(Integer id){
        return articleMapper.getUserInfoByArtId(id);
    }

    public List<ArticleInfo> getListByLikeTitle(String key) {

        return articleMapper.getListByLikeTitle(key);
    }

}
